using System;
using System.Collections.Generic;
using UnityEngine;

namespace Features
{

    [CreateAssetMenu(fileName = "Summon", menuName = "Features/召唤", order = 4)]
    public class Summon : Feature
    {
        public Pawn SummonPrefab;
        public float BasedHealth;
        public override void CancleEffect(FeatureEventArgs args)
        {

        }

        public override void ExecuteEffect(FeatureEventArgs args)
        {
            var node = args.TargetGridNode;
            if (node == null)
                return;
            if (node.Pawn != null)
                return;
            var Summons = PawnBuilder.InitPawnByPrefab(SummonPrefab);
            Summons.InitFeaturesListen();
            Summons.Property.HealPoint = BasedHealth;
            Summons.campIsSelf = args.pawn.campIsSelf;

            node.Pawn = Summons;
            Summons.gridNode = node;
            GridManager.instance.BattlePawns.Add(Summons);
            Summons.PawnAnchor.AnchorPosition = node.GetComponent<CardPosition>();
            node.GetComponent<CardPosition>().SetPawn(Summons);
            Summons.transform.position = Summons.gridNode.transform.position;


            SpriteTextManager.NewEffectText("召唤", Summons.transform.position.x, Summons.transform.position.y, Color.blue);

            Summons.OnStart();
        }

        public override string GetDescription()
        {
            return GetTriggerText() + "召唤一个"+SummonPrefab.name.Split('(')[0];
        }
    }
}